//
//  WaitingRepairChooseViewController.m
//  GetPowerDBO
//
//  Created by 周博 on 2017/7/17.
//  Copyright © 2017年 BogoZhou. All rights reserved.
//

#import "WaitingRepairChooseViewController.h"
#import "BorderHelper.h"

@interface WaitingRepairChooseViewController ()
{
    
}
@end

@implementation WaitingRepairChooseViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self UISetting];
}

- (void)UISetting{
    
    _buttonBackground.backgroundColor = [kBlackColor colorWithAlphaComponent:0.3];
    [self setItems];
    UIButton *button ;
    if (_typeValue.integerValue == 3) {
        button = (UIButton *)[self.view viewWithTag:101];
    }else if (_typeValue.integerValue == 2){
        button = (UIButton *)[self.view viewWithTag:102];
    }else if (_typeValue.integerValue == 1){
        button = (UIButton *)[self.view viewWithTag:103];
    }else{
        button = (UIButton *)[self.view viewWithTag:104];
    }
    [self typeButtonClick:button];
    [self setFuncItems];
}

- (void)setItems{
    [BorderHelper setBorderWithColor:ke6e6e6 view:_button00];
    [BorderHelper setBorderWithColor:ke6e6e6 view:_button01];
    [BorderHelper setBorderWithColor:ke6e6e6 view:_button10];
    [BorderHelper setBorderWithColor:ke6e6e6 view:_button11];
    if ([BGFunctionHelper isNULLOfString:_typeValue]) {
        _typeValue = @"3";
    }
}

- (void)setFuncItems{
    [BorderHelper setBorderWithColor:ke6e6e6 view:_buttonCancel];
    _buttonSure.backgroundColor = kGreenColor;
    
}

- (void)chooseButtonTypeWithButton:(UIButton *)button{
    button.layer.borderColor = [kGreenColor CGColor];
    button.layer.borderWidth = 0.5f;
    [button setTitleColor:kGreenColor forState:UIControlStateNormal];
    button.backgroundColor = [kGreenColor colorWithAlphaComponent:0.2];
}
#pragma mark - 点击事件

- (IBAction)backgroundButtonClick:(UIButton *)sender {
    [self dismissViewControllerAnimated:YES completion:nil];
}

//点击叹号弹出提示
- (IBAction)alertButtonClick:(UIButton *)sender {
    [self alertVCByTitle:@"只要存在一台离线设备就归入待维护门店"];
}

/**
 
 buttonType ;101 >60 ; 102 30< <60 ; 103 <30 ;104 all
 
 */
- (IBAction)typeButtonClick:(UIButton *)sender {
    if (sender.tag == 101) {
        _typeValue = @"3";
    }else if (sender.tag == 102){
        _typeValue = @"2";
    }else if (sender.tag == 103){
        _typeValue = @"1";
    }else{
        _typeValue = @"4";
    }
    [self setItems];
    [self chooseButtonTypeWithButton:sender];
}


/**
 
 button 201 cancel ; 202 sure

 */
- (IBAction)funcButtonClick:(UIButton *)sender {
    if (sender.tag == 201) {
        //cancel
        [self dismissViewControllerAnimated:YES completion:nil];
    }else{
        //sure
        [_delegate getChooseItem:_typeValue];
        [self dismissViewControllerAnimated:YES completion:nil];
    }
}

#pragma mark - alert

- (void)alertVCByTitle:(NSString *)title{
    UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:title preferredStyle:UIAlertControllerStyleAlert];
    
    UIAlertAction *action = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {

    }];
    
    [alert addAction:action];
    [self presentViewController:alert animated:YES completion:nil];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
